package com.xigege.nio.NIO案例;

import java.io.IOException;
import java.net.InetSocketAddress;
import java.nio.channels.SocketChannel;
import java.nio.charset.StandardCharsets;

/**
 * @author huangxi
 * @class NIOBlockClient
 * @description NIOBlockClient
 * @create 2022-08-15 16:36
 */
public class NIOBlockClient {
    public static void main(String[] args) throws IOException {
        SocketChannel sc = SocketChannel.open();

        sc.connect(new InetSocketAddress("localhost", 6666));

        System.out.println("连接上了");

        sc.write(StandardCharsets.UTF_8.encode("hehhhhehhhehhehheheh1"));
        sc.write(StandardCharsets.UTF_8.encode("hehhhhehhhehhehheheh2"));
        sc.write(StandardCharsets.UTF_8.encode("hehhhhehhhehhehheheh3"));

        sc.close();
    }
}
